import { defineStore } from "pinia";
import {reqHospitalDetail,reqHospitalDepament} from "../../api/hospital/index"
import type { HospitalDetail,HospitalStore,DepartmentResponseData } from "../../api/hospital/type";
 const useDetailStore = defineStore('Detail',{
    state:():HospitalStore=>{
        return {
            // 存储医院详情数据
           hospitalInfo:({} as HospitalDetail),
            //存储医院科室信息
            departmentArr:[] 
        }
    },
    actions:{
        // 获取医院详情的方法
        async getHospital(hoscode:string){
           let result:HospitalDetail = await reqHospitalDetail(hoscode);
            if (result.code == 200) {
                this.hospitalInfo = result.data;
                // console.log(result);    
            }  
        },
        // 获取医院科室信息的方法
        async getDeparment(hoscode:string){
          let result:DepartmentResponseData =  await reqHospitalDepament(hoscode);
          if (result.code==200) {
            this.departmentArr = result.data;
            // console.log(result.data);
          }
        }
    },
    getters:{

    }
});
// 获取仓库的方法对外暴露
export default useDetailStore;